<%-- 
    Document   : formAjoutCreneau2
    Created on : 29 mars 2013, 14:13:39
    Author     : ali
--%>


  
<%@page import="EDT.obj.Ec"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.text.DateFormat"%>
<%@page import="java.util.Date"%>
<%@page import="java.util.Calendar"%>
<%@page import="java.util.HashMap"%>
<%@page import="java.util.ArrayList"%>
<%@page import="EDT.obj.Formation"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
                
        <title>Ajouter des Créneaux </title>
            <link rel="stylesheet" href="Accueil.css" />
            <link rel="SHORTCUT ICON" href="./edt.jpg" />
    </head>


    <body>    
         
    <section>
        
        <%
        
        String form ="";
    
    
        ArrayList<Formation> formation = new ArrayList<Formation>();
        
        formation = (ArrayList<Formation> ) session.getAttribute("formation");
        form +="<form method='POST' action='/EDT/AjoutCreneau3.do' target='section'>\n";
        form += "<div class='commentaire'>\n";
        form += "<fieldset>";
        
        
        
        form += "<legend>    Choisissez une promotion et une periode :   </legend>";
        form += "<input type='hidden' name='key' value='"+session.getAttribute("key")+"'/>";
        
        String s =request.getParameter("formation");
        int idf = Integer.parseInt(s);
       
        form += "<input type='hidden' name='formation' value='"+idf+"'/>";
        
        Calendar c = Calendar.getInstance();
        c.setTime(new Date());
        DateFormat dateFormat = new SimpleDateFormat("yyyy");
        
        form += "Promotion :   <select name='promo'>";
        
        for (Formation f : formation)
            if (f.getId() == idf){
              HashMap<Integer, Integer> hashMap = f.getLesPromos();
                for (Integer mapKey : hashMap.keySet()){
                    if (hashMap.get(mapKey)+1>= Integer.parseInt(dateFormat.format(c.getTime())))
                    form += "<option value='"+mapKey+"'>"+hashMap.get(mapKey)+"/"+(hashMap.get(mapKey)+1)+"</option>";
                }
                form += "</select><br/><br/>";
                
              form += "<input type='hidden' name='nbrPeriode' value='"+f.getPeriodes()+"'/>";
              
             form += "Periode :   <select name='periode'>";
                for (int i = 1; i<= f.getPeriodes();i++)
                    form += "<option value='"+i+"'>"+i+"</option>";
                form += "</select><br/><br/>";
            } 

        
        form += "<input type='submit' value='valider'/><br/>";
        
        out.println(form);
       
                
%>
        
     
    <html:errors/> 
    
    </fieldset>
    
        
    </div>

    </form>
         
    </section>
    </body>
</html>
